package com.yiwei.zhh.impl;

import android.content.Context;

import com.yiwei.zhh.constant.Const;
import com.yiwei.zhh.http.CallBackListener;
import com.yiwei.zhh.http.InterfaceServer;
import com.yiwei.zhh.interfaces.IdentityInfo;
import com.yiwei.zhh.http.InfoCallBack;
import com.yiwei.zhh.model.IdentityModel;
import com.yiwei.zhh.model.RequestModel;
import com.yiwei.zhh.model.ResponseModel;

import java.util.HashMap;

/**
 * 身份证
 */
public class IdentityInfoImpl implements IdentityInfo {

    /**
     * 识别身份证
     *
     * @param paramContext
     * @param paramInt
     * @param paramString
     * @param callBack
     */
    public void getIdentityInfo(Context paramContext, int paramInt, String paramString, final InfoCallBack callBack) {
        HashMap localHashMap = new HashMap();
        localHashMap.put("img", paramString);
        RequestModel model = new RequestModel(localHashMap);
        InterfaceServer.getInstance(paramContext.getApplicationContext()).requestInterface(Const.IDCARD + paramInt, Const.RequestMethod.POST, model, Const.DEFAULT_TIMEOUT,new CallBackListener<IdentityModel>(IdentityModel.class,callBack));
//                new ResponseListener() {
//            public void onFinishInMainThread(Object paramAnonymousObject) {
//            }
//
//            public void onStartInMainThread(Object paramAnonymousObject) {
//                callBack.onFailure(paramAnonymousObject.toString());
//            }
//
//            @Override
//            public void onSuccessInMainThread(int paramAnonymousInt, String paramAnonymousString, Object result) {
//                try {
//                    IdentityModel model = (IdentityModel) result;
//                    if (model.getStatus() == 1)
//                        callBack.onSuccess(model);
//                    else callBack.onFailure(model.getMsg());
//                    //返回数据接口
//                } catch (Exception e) {
//                    e.printStackTrace();
//                }
//            }
//
//            @Override
//            public Object onSuccessInRequestThread(int statusCode, String content) {
//                try {
//                    return JsonUtil.<IdentityModel>fromJson(content, IdentityModel.class);
//                } catch (Exception e) {
//                    return null;
//                }
//            }
//        });
    }

    /**
     * 上传身份证
     *
     * @param paramContext
     * @param model
     * @param callBack
     */
    @Override
    public void getSubmitidCard(Context paramContext, IdentityModel model, final InfoCallBack callBack) {
        RequestModel rModel = new RequestModel(model);
        InterfaceServer.getInstance(paramContext.getApplicationContext()).requestInterface(Const.SUBMIT_IDCARD, Const.RequestMethod.POST, rModel, Const.DEFAULT_TIMEOUT,new CallBackListener<ResponseModel>(ResponseModel.class,callBack));
//                new ResponseListener() {
//            public void onFinishInMainThread(Object paramAnonymousObject) {
//            }
//
//            public void onStartInMainThread(Object paramAnonymousObject) {
//                callBack.onFailure(paramAnonymousObject.toString());
//            }
//
//            @Override
//            public void onSuccessInMainThread(int paramAnonymousInt, String paramAnonymousString, Object result) {
//                try {
//                    ResponseModel model = (ResponseModel) result;
//                    if (model.getStatus() == 1)
//                        callBack.onSuccess(model);
//                    else callBack.onFailure(model.getMsg());
//                    //返回数据接口
//                } catch (Exception e) {
//                    e.printStackTrace();
//                }
//            }
//
//            @Override
//            public Object onSuccessInRequestThread(int statusCode, String content) {
//                try {
//                    return JsonUtil.<ResponseModel>fromJson(content, ResponseModel.class);
//                } catch (Exception e) {
//                    return null;
//                }
//            }
//        });
    }
}
